
-- procedure to update a contact
-- return 1 if can update, 0 cannot update
IF OBJECT_ID('updateContact') IS NOT NULL
BEGIN
	DROP PROCEDURE updateContact; 
END
GO
CREATE PROCEDURE updateContact
	@contactId		INT,
	@userId			INT,
	@contactName	VARCHAR(30),
	@contactType	VARCHAR(12)
AS
BEGIN
	IF EXISTS(SELECT * FROM [contact] WHERE contactid=@contactId)
		BEGIN
			UPDATE [CONTACT] SET userid=@userId, contact=@contactName, contacttype=@contactType WHERE contactid=@contactId;
			SELECT 1;
		END
	ELSE
		BEGIN
			SELECT 0;
		END
END
GO

